Sự khác biệt giữa substr và substring

string,tipjs

substr() Hình thức của hàm là substr(startIndex,length). Nó startIndex trả về từ chuỗi con và trả về length số lượng ký tự.

var s = "hello";
( s.substr(1,4) == "ello" ) // true

substring()Hình thức của hàm là substring(startIndex,endIndex). Nó trả về chuỗi con từ startIndex đến endIndex - 1.

var s = "hello";
( s.substring(1,4) == "ell" ) // true

Có thể bạn đã miss một số snippets code

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.

Merge Array

How to combine two sorted arrays into one? We can do this easily with the spread operator.

Copy a string to the clipboard

Copy a string to the clipboard. Only works as a result of user action (i.e. inside a click event listener).

JavaScript: async/await with forEach

JavaScript: async/await with forEach()

Converting Object to an Array

Converting Object to an Array