Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

what is fn.call

const animals = [
  { species: 'Lion', name: 'King' },
  { species: 'Whale', name: 'Fail' }
];

for (let i = 0; i < animals.length; i++) {
  (function(i) {
    this.print = function() {
      console.log('#' + i + ' ' + this.species
                  + ': ' + this.name);
    }
    this.print();
  }).call(animals[i], i);
}
Comment

what is fn.call

function Product(name, price) {
  this.name = name;
  this.price = price;
}

function Food(name, price) {
  Product.call(this, name, price);
  this.category = 'food';
}

function Toy(name, price) {
  Product.call(this, name, price);
  this.category = 'toy';
}

const cheese = new Food('feta', 5);
const fun = new Toy('robot', 40);
Comment

PREVIOUS NEXT
Code Example
Python :: last element of python list 
Python :: python timedelta get days with fraction 
Python :: decision tree algorithm 
Python :: dbscan example 
Python :: flatten list in python 
Python :: python combinations function 
Python :: programmer tool 
Python :: delete list using slicing 
Python :: count number of subdirectories 
Python :: python derivative of mean squared error 
Python :: # convert string to date 
Python :: sudo in python 
Python :: python grab results from cursor.execute 
Python :: change a coolumn datatype in pandas 
Python :: bar chart in python 
Python :: How to take multiple inputs in one line in python using list comprehension 
Python :: python list of dict change dicts id by position in list when moved 
Python :: compiling python code 
Python :: python reading into a text file and diplaying items in a user friendly manner 
Python :: Write a simple python program that adds 2 numbers togethe 
Python :: ide for python 
Python :: discord.py send message to channel with mutiple id 
Python :: iterrows pd 
Python :: state capitals python 
Python :: how to check if element is in list python 
Python :: python generator function 
Python :: how to iterate a list in reverse order in python with index 
Python :: 12 month movinf average in python for dataframe 
Python :: python digit string 
Python :: python selenium click on agree button 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =