-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[js] 第102天 准确说出'1,2,3,4'.split()的结果是什么(包括类型和值)? #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
'1,2,3,4'.split()
的结果是什么(包括类型和值)?
["1,2,3,4"] 结果为一个长度为1的数组 元素的值类型为字符串 |
上面的同学说的第二个参数的含义有一点错误 let a = '1,2,3,4,5,6';
a.split(',', 3); // 返回的结果为 ["1", "2", "3"]
a.split(',', 5); // 返回的结果为 ["1", "2", "3", "4", "5"] 如果说split内没有参数值的话,就默认将整个字符串作为一个元素返回一个长度为1的Array |
'1false2'.split(false) // ['1', '2']
'1true2'.split(true) // ['1', '2']
'1null2'.split(null) // ['1', '2']
'1[object Object]2'.split({}) // ['1', '2']
'1undefined2'.split(undefined) // ["1undefined2"] javascript 太难了。。。 |
'1,2,3,4'.split() // ["1,2,3,4"] |
返回一个数组:[1,2,3,4] |
[ '1,2,3,4' ] |
答案为
|
|
return "[1,2,3,4]" 是个字符串 |
第102天 准确说出
'1,2,3,4'.split()
的结果是什么(包括类型和值)?The text was updated successfully, but these errors were encountered: