<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script> //length:获取字符串长度 var str='my name is very'; console.log(str.length);//15 //console.log('沙漠"+‘骆驼"); //只要有字符串和其他类型拼接,最终结果都是字符串类型 console.log( '即兴'+'小索奇');//字符串-即兴小索奇 console.log('天天'+true);//天天true console.log(12+12);//24 console.log('12'+12);//1212 //分享小技巧————输入console.log( '即兴'+'小索奇')时可以先输入console.log(''++ '') //简记引引加加''++'' console.log( '即兴'+plus+'小索奇'); </script> </head> <body> </body> </html>
每日更新新代码,体系进阶~