Friday, March 2, 2018

.includes off of an array

It does what you'd expect in JavaScript and this has this example:

var array1 = [1, 2, 3];
console.log(array1.includes(2));
var pets = ['cat', 'dog', 'bat'];
console.log(pets.includes('cat'));
console.log(pets.includes('at'));

 
 

This is going to log to the console:

  1. true
  2. true
  3. false

No comments:

Post a Comment