js ar code example
Example 1: javascript array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 2: js array
var colors = [ "red", "orange", "yellow", "green", "blue" ];
console.log(colors);
console.log(colors[0]);
console.log(colors[1]);
console.log(colors[4]);
colors[4] = "dark blue"
console.log(colors[4]);
Example 3: array javascript
var fruits = ['Apple', 'Banana'];
console.log(fruits.length);
var first = fruits[0];
var last = fruits[fruits.length - 1];
fruits.forEach(function(item, index, array) {
console.log(item, index);
});
var newLength = fruits.push('Orange');
var last = fruits.pop();
var first = fruits.shift();
var newLength = fruits.unshift('Strawberry')
fruits.push('Mango');
var pos = fruits.indexOf('Banana');
var removedItem = fruits.splice(pos, 1);
var vegetables = ['Cabbage', 'Turnip', 'Radish', 'Carrot'];
console.log(vegetables);
var pos = 1, n = 2;
var removedItems = vegetables.splice(pos, n);
console.log(vegetables);
console.log(removedItems);
Example 4: js arrays
const colors = ["red", "orange", "yellow"];
colors[0];
colors.length;
Example 5: ar.js getting started
<script src="https://raw.githack.com/AR-js-org/AR.js/3.0.0/aframe/build/aframe-ar-nft.js">
Example 6: ar.js getting started
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js">