Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, February 19, 2018

Remove duplicates from an array in Javascript

Consider an array=[1,2,3,3,2,4,1,1]

We need to write a function to remove duplicates from an array.

function(arr){
let unique=[];

for(let i=0;i<arr.length;i++){

if(unique.indexOf(arr[i])== -1)
{
unique.push(arr[i]);
}
}
}
return unique;
}

Tuesday, September 26, 2017

JavaScript

JavaScript is a lightweight, cross platform, object oriented programming language.

lightweight: it takes very less system memory

cross platform: can be run on multiple platforms and systems

object oriented : js is a language based on object

JavaScript is one of the three core technologies(HTML & CSS)

JavaScript is most commonly used as a part of webpages. It can be used in different places.
  • Client Side : JavaScript was used only in browser  for many years.
  • Server Side : With development of Node.js we are able to use JavaScript in the server side as well.
JavaScript made modern web development possible. With JS we are able to have dynamic effects and are building modern web applications that we can interact with.

Saturday, April 22, 2017

p5.js

p5.js is a JavaScript library which can be used by artists,designers,educators and beginners who want to code. Using p5.js we have a full set of drawing functionality and this is not limited to canvas alone, we can make use of addon libraries from p5.js and easily interact with other html objects like text, input, video, webcam and sound.

Friday, April 14, 2017

How to pass a number with leading zero as decimal value to a function in JavaScript?

In JavaScript a number with leading zeros is considered to be in Octal system and it is read as octal value.

Ex:"0025" is read as "21".

In order to have its value preserved we should pass it as string.

Ex: myfunction(x){
   
alert(x);
}

we should call function as myfunction("0026")

Call a function in child component from parent component in React

Consider the following parent component class Parent extends React.Component { constructor(props) { super(props);         thi...