yaml
npm install --save yamljs
Here is what the above code is Doing:
1. We’re importing the yamljs module.
2. We’re loading the yaml file into a variable.
3. We’re printing the contents of the yaml file.
npm install --save yamljs
Here is what the above code is Doing:
1. We’re importing the yamljs module.
2. We’re loading the yaml file into a variable.
3. We’re printing the contents of the yaml file.
created() { fetch(‘test.json’) .then(resp => resp.json()) .then(items => { this.items = items; const descEl = document.querySelector(‘head meta[name=”description”]’); const titleEl = document.querySelector(‘head title’); descEl.setAttribute(‘content’, items[0][‘meta-desc’]); titleEl.textContent = items[0][‘meta-title’]; }) } Here is what the above code is Doing: 1. We’re using the `created()` lifecycle hook to fetch the JSON file. 2. We’re using the `fetch()` API…
for key, value in json_data.iteritems(): print key if isinstance(value, (list, tuple)): for item in value: print item if isinstance(value, (dict)): for value_key,value_value in value.iteritems(): print value_key,str(value_value) Here is what the above code is Doing: 1. It’s iterating over the keys in the json_data dictionary. 2. It’s checking if the value of the key is a…
handleEntailmentRequest(e) { e.preventDefault(); console.log(“handle request “); } Here is what the above code is Doing: 1. We’re importing the React library and the Component class from the react module. 2. We’re creating a new class called App and we’re extending the React.Component class. 3. We’re defining a render method that returns a div element. 4….
function getMeta(url, callback) { var img = new Image(); img.src = url; img.onload = function() { callback(this.width, this.height); } } getMeta( “http://snook.ca/files/mootools_83_snookca.png”, function(width, height) { alert(width + ‘px ‘ + height + ‘px’) } ); Here is what the above code is Doing: 1. Create a new Image object. 2. Set the src attribute to…
// STATEMENT: Code that performs actions (generally something that ends in “;” // example: const str = `String assigned to str`; // EXPRESSION: Code that produces a value // example(s): 3 + 4 1991 true && false && false Here is what the above code is Doing: 1. The first line is a STATEMENT that…
let arr = [ [1, 2], [3, 4], [5, 6][7, 8, 9], [10, 11, 12, 13, 14, 15] ]; let flatArray = arr.reduce((acc, curVal) => { return acc.concat(curVal) }, []); //Output: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] Here is what the above code is…