my_string = "Hello how are you"
console.log my_string
// Generated by CoffeeScript 1.10.0 (function() { var my_string; my_string = "Hello how are you"; console.log(my_string); }).call(this);
new_string = "Hello how are you "+"Welcome to Tutorialspoint" console.log new_String
// Generated by CoffeeScript 1.10.0 (function() { var new_string; new_string = "Hello how are you " + "Welcome to Tutorialspoint"; console.log(new_String); }).call(this);
Hello how are you Welcome to Tutorialspoint
name = "Raju" age = 26 message ="Hello #{name} your age is #{age}" console.log message
// Generated by CoffeeScript 1.10.0 (function() { var age, message, name; name = "Raju"; age = 26; message = "Hello " + name + " your age is " + age; console.log(message); }).call(this);
Hello Raju your age is 26
name = "Raju" age = 26 message ='Hello #{name} your age is #{age}' console.log message
Hello #{name} your age is #{age}
my_string = "hello how are you Welcome to lidihuo Have a nice day." console.log my_string
hello how are you Welcome to tutorialspoint Have a nice day.
方法和说明 |
charAt()
返回指定索引处的字符。
|
charCodeAt()
返回一个数字,表示给定索引处字符的 Unicode 值。
|
concat()
组合两个字符串的文本并返回一个新字符串。
|
indexOf()
返回指定值第一次出现的调用 String 对象内的索引,如果未找到,则返回-1、
|
lastIndexOf()
返回指定值最后一次出现的调用 String 对象内的索引,如果未找到,则返回-1、
|
localeCompare()
返回一个数字,指示参考字符串在排序顺序中是在给定字符串之前还是之后,还是与给定字符串相同。
|
match()
用于将正则表达式与字符串匹配。
|
search()
执行正则表达式和指定字符串匹配的搜索。
|
slice()
提取字符串的一部分并返回一个新字符串。
|
split()
通过将字符串分成子字符串,将字符串对象拆分为字符串数组。
|
substr()
返回从指定位置开始到指定字符数的字符串中的字符。
|
toLocaleLowerCase()
在尊重当前语言环境的同时,字符串中的字符被转换为小写。
|
toLocaleUpperCase()
在尊重当前语言环境的同时,字符串中的字符被转换为大写。
|
toLowerCase()
返回转换为小写的调用字符串值。
|
toUpperCase()
返回转换为大写的调用字符串值。
|