Unload js object

Unload js object

//Not sure if this will work, Haven’t tested it yet but it makes sense. function fnc1() { console.log(“I did something”) } window.fnc1 = null //or window[“fnc1”] = null //see the source below Here is what the above code is Doing: 1. It creates a function called fnc1 2. It assigns the function to the window…

python convert two lists with duplicates to dictiona

python convert two lists with duplicates to dictiona

dict_1={} for key,value in zip(list_one,list_two): if key not in dict_1: dict_1[key]=[value] else: dict_1[key].append(value) print(dict_1) Here is what the above code is Doing: 1. We create an empty dictionary called dict_1. 2. We use a for loop to iterate through the elements of list_one and list_two. 3. We use the zip() function to iterate through the…

Simple nested array issue in strapi

Simple nested array issue in strapi

module.exports = { /** * Promise to fetch all records * * @return {Promise} */ find(params, populate) { return strapi.query(‘default’).find(params, [“section”, “section.content”]); }, }; Here is what the above code is Doing: 1. We are importing the strapi query builder. 2. We are using the query builder to fetch all records from the default model….

Following Links in Python

Following Links in Python

import urllib from BeautifulSoup import * URL = raw_input(“Enter the URL:”) #Enter main URL link_line = int(raw_input(“Enter position:”)) – 1 #The position of link relative to first link count = int(raw_input(“Enter count:”)) #The number of times to be repeated while count >= 0: html = urllib.urlopen(URL).read() soup = BeautifulSoup(html) tags = soup(‘a’) print URL URL…

foreach on dictionary in typescript

foreach on dictionary in typescript

for (const [key, value] of Object.entries(yourDictionary)) { console.log(`(${key}, ${value})`); } Here is what the above code is Doing: 1. We’re using the Object.entries() method to get an array of key/value pairs from our object. 2. We’re looping through each of these pairs using for…of. 3. We’re destructuring the key and value from each pair inside…