Website Hosting for Just 20 ForumCoin ~ Advertise on ForumCoin
52 Life Tips Banner
Webmaster forum. Website development, design & management. Graphic design. Blog / Forum Set-up, Management, Admin & News

JavaScript Tips & Tricks

Postby GuestHu » 08 Apr 2021, 05:21

1. Substitute for .map()
let cats= [
{ name: ‘Cutie’, age: 3 },
{ name: ‘Pussy’, age: 2 },
{ name: ‘Cathy’, age: 1 },
{ name: ‘Kitkat’, age: 9 },
{ name: ‘Meowth’, age: 5 },
];

let catsNames = Array.from(cats, ({name}) => name);
console.log(catsNames); // returns [“Cutie”, “Pussy”, “Cathy”, “Kitkat”, “Meowth”]


2. Converting Number to string or string to number
let number = 15;
let numString = number + ""; // number to string
let stringNum = +s; // string to number

3. Removing duplicates from an Array
const array = [1, 3, 2, 3, 2, 1, true, false, true, 'Cats', 2, 3];
const filteredArray = [...new Set(array)];
console.log(filteredArray) // [1, 3, 2, true, false, "Cats"]

4. Short For Loop
const names = ["Angie", "Rina", "Ruby"];

// Long Version
for (let i = 0; i < names.length; i++) {
const name = names[i];
console.log(name);
}

// Short Version
for (let name of names) console.log(name);
  • 2

User avatar
GuestHu
 
Posts: 1,402
ForumCoin: 749

Re: JavaScript Tips & Tricks

Postby chikitta » 08 Apr 2021, 10:20

Aha you have just made my life easier with java script, this tricks are good thanks for sharing.
  • 1

chikitta
 
Posts: 5,050
Referrals: 1
ForumCoin: 354

Re: JavaScript Tips & Tricks

Postby ptrikha21 » 10 Apr 2021, 12:37

The Short version of For and removing duplicates looks good. Some of my colleagues are working on JavaScript / JSP pages and would find this useful.
  • 1

User avatar
ptrikha21
 
Posts: 7,387
Location: India
Referrals: 5
ForumCoin: 1,113

Re: JavaScript Tips & Tricks

Postby Alive20 » 23 Apr 2021, 15:41

The codes you wrote could be handy. JavaScript is essential for websites and there is no denying that.
  • 0

Alive20
 
Posts: 200
ForumCoin: 126

Re: JavaScript Tips & Tricks

Postby ranamal » 12 Jul 2021, 04:39

Good tips thankyou, and there are lot of awesome tips available on Google
  • 0

ranamal
 
Posts: 504
Referrals: 1
ForumCoin: 26

Re: JavaScript Tips & Tricks

Postby sethbala11 » 20 Jul 2021, 21:57

For someone who wants to learn the web programming especially front end programming it is very important that you have a good knowledge of JavaScript
  • 0

sethbala11
 
Posts: 211
ForumCoin: 2

Re: JavaScript Tips & Tricks

Postby arunima » 21 Jul 2021, 11:57

It's a shame that I learnt Java, HTML, VB, C and C++ in my post-graduate diploma course in Bioinformatics and I used them a lot. But then it has been almost 15 years since I made a lateral shift in my career and have not used them. Now they sound so alien to me.
Java Script is very handy in front end programming.
  • 0

arunima
 
Posts: 5,968
Location: India
Referrals: 1
ForumCoin: 1,847

Re: JavaScript Tips & Tricks

Postby GuestHu » 27 Jul 2021, 08:03

arunima wrote:Java Script is very handy in front end programming.

Also, JS can be used in the back-end part. NodeJS is a popular back-end tool.
  • 0

User avatar
GuestHu
 
Posts: 1,402
ForumCoin: 749



Your Ad Here.

Return to Webmaster Questions, Discussion & News



Who is online

Users browsing this forum: Claude [Bot] and 0 guests

Reputation System ©'