“Substring di JavaScript” Kode Jawaban

JavaScript mendapatkan 10 karakter string pertama

var str = "Hello world That is reallly neat!";
var res = str.substring(0, 5);//get first 5 chars
Grepper

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

Substring

const str = 'Mozilla';

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

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

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

Substring di JavaScript

const str = "Learning to code";

// 3 ways to get substring in javascript
// 1. substring() method
// 2. slice() method
// 3. substr() method

console.log(str.substring(0, 5));
console.log(str.substring(0, 5));
console.log(str.substr(2, 5));
Clumsy Caiman

Jawaban yang mirip dengan “Substring di JavaScript”

Pertanyaan yang mirip dengan “Substring di JavaScript”

Lebih banyak jawaban terkait untuk “Substring di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya