Skip to content

Commit

Permalink
Add delete operator example
Browse files Browse the repository at this point in the history
Closes: #5
  • Loading branch information
moonkxn authored and tshemsedinov committed Sep 30, 2017
1 parent 6201f3f commit af006da
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions JavaScript/7-delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';

const org = 'HowProgrammingWorks';

// delete org; // Raises SyntaxError in strict mode

const country = {
name: 'Chile',
ruler: 'Augusto Pinochet',
born: 1915,
alive: false
};

delete country.ruler;
console.dir({ country });

delete country.born;
delete country.population;
console.dir({ country });

const currencies = ['BTC', 'EUR', 'UAH', 'USD'];

console.log('currencies[1]:', currencies[1], 1 in currencies);
console.log('currencies[2]:', currencies[2], 2 in currencies);

delete currencies[1];
currencies[2] = undefined;
console.dir({ currencies });

console.log('currencies[1]:', currencies[1], 1 in currencies);
console.log('currencies[2]:', currencies[2], 2 in currencies);

0 comments on commit af006da

Please sign in to comment.