_.implode()方法用於將字符串數組放大為單個字符串。
用法:
_.implode( array );
參數:
- array:此方法需要一個數組內爆。
返回值:此方法返回生成的String。
注意:由於它需要安裝underscore.js contrib庫,因此在正常的JavaScript中將無法使用。
可以使用npm install underscore-contrib -save安裝underscore.js contrib庫。
範例1:
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var s = _.implode( ["G", "e", "e", "k",
"s", "f", "o", "r",
"G", "e", "e", "k", "s"] );
console.log("The generated String is:", s);
輸出:
The generated String is: GeeksforGeeks
範例2:
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var s = _.implode( ["C", "o", "m", "p", "u", "t",
"e", "r", " ", "S", "c", "i",
"e", "n", "c", "e", " ", "P",
"o", "r", "t", "a", "l"] );
console.log("The generated String is:", s);
輸出:
The generated String is: Computer Science Portal
相關用法
- PHP implode()用法及代碼示例
- Node.js GM implode()用法及代碼示例
- ASP End用法及代碼示例
- d3.js curveLinearClosed()用法及代碼示例
- ASP Clear用法及代碼示例
- d3.js scaleLinear()用法及代碼示例
- d3.js curveLinear()用法及代碼示例
- d3.js line.x()用法及代碼示例
- d3.js line()用法及代碼示例
- ASP BinaryWrite用法及代碼示例
- d3.js line.y()用法及代碼示例
- d3.js lineRadial()用法及代碼示例
- Lodash _.nth()用法及代碼示例
注:本文由純淨天空篩選整理自taran910大神的英文原創作品 Underscore.js _.implode() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。