Prototyping in JavaScript
Prototyping in JavaScript
The prototype property is an object (called as prototype object) has a constructor property by default. constructor property points back to the function on which the prototype object is a property. We can access the function’s prototype property using the syntax functionName.prototype.
I usually loved to work on Python has many inbuilt methods like the title.
While working on the front-end part I prefer to use JQuery or Plain Vanilla javascript. I found some lack of method like the title. So I decided to build a method which does the same action as the title in python.
First, I build a simple method which takes a string as an argument which makes the title for that string.
After 5-6 months working in front-end technology, I came to know about Prototyping in Javascript.
Prototype for the title the string.
String.prototype.title = function() {
if (this == "None" || this == "") {
return "-"
}
var string = this.toLowerCase()
string = string.replace(/(^|\s)[a-z]/g,function(f){return f.toUpperCase();});
return string.replace(/_/g, " ").replace(/-/g, " ")
}
Prototype for the INR Symbol.
Number.prototype.getINR = function() {
return this.toLocaleString('en-IN',{
maximumFractionDigits: 2,
style: 'currency',
currency: 'INR'})
}
usage: let amount = 50
amount.getINR()
console.log(amount)
> '
₹ 50.0'
This is really a good source of information, I will often follow it to know more information and expand my knowledge, I think everyone should know it, thanks Best Rapid prototyping service provider
ReplyDeleteNo deposit bonus casinos 2021 | How to get free spins no deposit
ReplyDeleteMost 먹튀검증소 casinos 19 동인지 will limit you to 5 no deposit spins with no deposit 가상축구 required to activate any bonus without 토팡 any deposit required. However, in addition to free spins, 토토사이트 관리 알바 벳피스트
The Lion King (SNES / Mega Drive) Review - CasinoWow
ReplyDeleteThe Lion King is a game you might want to revisit online. Released 5 years ago on the SEGA Mega Drive back in 1988, this 카지노사이트 game was available Pros and cons include: The 메리트카지노 Lion King is a little slow paced but definitely worth the price you could have