Premium Only Content

call() method in JavaScript ( #shorts )
Hi Friends,
call() method in JavaScript
In JavaScript, `call()` method is used to call a function with a specific `this` value and argument
eg: There is a object `Human` with `name` property & function `welcome()` that will show a welcome message with name of Human. `call()` is use to set the `this` value of `welcome()` to the `Human` object & pass the `name` property as an argument.
const human = {
name: "David",
welcome: function(message) {
console.log(`${message}, ${this.name}!`);
}
};
human.welcome("Hello"); // Output: Hello, David!
// Using call() to call wekcome() with a different message and this value
human.welcome.call({ name: "Sarah" }, "Hi"); // Output: Hi, Sarah!
Using `call()` allows us to reuse the `welcome()` function for different objects and control the `this` value and arguments passed to it.
#javascript #call #callmethod #string #javascriptinterview #method #js #jquery #function #shorts #viral #popular #latest #new #famous #coders #development #code #dev #interview #php #trend #trending #answer #youtube #instagram #socialmedia #education #edit #gaming #how #india #knowledge #love #like #motivational #quiz #reels #short #subscribe #share #update #video #web #webdeveloper #website #webdesign #ytshorts #youtuber #princecheema_official @princecheema_official
-
2:26:44
Tundra Tactical
5 hours ago $0.18 earned🎉 Pro-2A Party LIVE! | Zeke Stout Joins The Show With Tacoma Tactical
964 -
2:36:47
BlackDiamondGunsandGear
7 hours agoAFTER HOURS ARMORY / The LEFT are Recruiting / Join the Leftist Gun Club?
7704 -
16:07
Ken LaCorte: Elephants in Rooms
11 hours agoWhy firefighting got political
3742 -
8:31
Rethinking the Dollar
15 hours agoBitcoin Secrets Nobody Talks About!
6924 -
2:36:47
DLDAfterDark
5 hours ago $0.35 earnedIs The Left Recruiting To KILL Conservatives? Hey Fascist, CATCH!
9051 -
22:53
Jasmin Laine
1 day agoParliament ERUPTS After "WORST Decision EVER!"—Carney Left SPEECHLESS by SHOCKING Report
29.7K73 -
11:50
Mrgunsngear
1 day ago $7.44 earnedSteiner MPS Enclosed Red Dot: Better Than The ACRO P2? 🔴
28.5K17 -
1:27:55
Sarah Westall
1 day agoSelecting World Leaders: Intelligence No Longer a Prerequisite w/ Martin Armstrong
38.2K21 -
2:03:07
Badlands Media
1 day agoDevolution Power Hour Ep. 393: Synthetic Reality, and the RICO Grande Strategy
65.2K24 -
11:23:18
GritsGG
12 hours agoQuad Win Streaks!🫡 Most Wins in WORLD! 3600+
77.3K10