「JavaScript入門」split()で配列の要素数を指定する

JSサンプルコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const cityStr = "Tokyo,Oosaka,YokoHama,FukuOka,Kawasaki";
const cftArr = cityStr.split(",",3);
console.log(cftArr);
const cityStr = "Tokyo,Oosaka,YokoHama,FukuOka,Kawasaki"; const cftArr = cityStr.split(",",3); console.log(cftArr);
const cityStr = "Tokyo,Oosaka,YokoHama,FukuOka,Kawasaki";

const cftArr = cityStr.split(",",3);

console.log(cftArr);

 

結果
[“Tokyo", “Oosaka","YokoHama"]

JavaScript

Posted by arkgame