Syntax
var anyVariableName1=yourValue1, anyVariableName2=yourValue2, anyVariableName3=yourValue3, ...
ตัวอย่างโค้ด
var firstName="My First Name is David", lastName="My Last Name is Miller", place="I live in AUS"; console.log(firstName); console.log(lastName); console.log(place);
วิธีรัน
node fileName.js
ชื่อไฟล์ demo182.js
ผลลัพธ์
PS C:\Users\Amit\javascript-code> node demo182.js My First Name is David My Last Name is Miller I live in AUS
คำอธิบาย
ใช้ comma (,) คั่นระหว่างการประกาศตัวแปรหลายตัวในบรรทัดเดียว ใช้ var/let/const ตัวแรกอย่างเดียว แนะนำให้ใช้ let/const ใน ES6+ แทน var