“JavaScript Substr” Code-Antworten

JS bekommen die ersten 3 Zeichen von String

const string = "0123456789";
console.log(string.slice(0, 2)); // "01"
console.log(string.slice(0, 8)); // "01234567"
console.log(string.slice(3, 7)); // "3456"
Modern Mouse

JS Substring

// the substring method returns a string out of another string

const str = 'Mozilla';

console.log(str.substring(1, 3));
// expected output: "oz"

console.log(str.substring(2));
// expected output: "zilla"
mikelikestocode

Substring JavaScript

var str = "Hello world!";
var res = str.substring(1, 4); //ell
Sleepy Swiftlet

substr () javaScript

const str = 'substr';

console.log(str.substr(1, 2)); // (1, 2): ub
console.log(str.substr(1)); // (1): ubstr

/* Percorrendo de trás para frente */
console.log(str.substr(-3, 2)); // (-3, 2): st
console.log(str.substr(-3)); // (-3): str
Cipriano98

Unterfunktion JavaScript

// Simple Substraction Function in Javascript
function sub(a, b) {
return a-b
}
console.log(sub(6, 2))
Dangerous Dunlin

JavaScript Substr

str.substring(/* starting_idx */, /* number_of_values_to_get */)
QuietHumility

Ähnliche Antworten wie “JavaScript Substr”

Fragen ähnlich wie “JavaScript Substr”

Weitere verwandte Antworten zu “JavaScript Substr” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen