all InfoSec news
Getters/setters in JavaScript
May 2, 2024, 5:11 p.m. | Simon Mei
DEV Community dev.to
Security and flexibility with getters and setters
In JavaScript, there are two kinds of object properties:
- Data properties:
let myObj = {name: "Joseph", surname: "Joestar"}
// name and surname are data properties
myObj.name // Joseph
- Accessor properties
let myObj = {
get name() {
return this._name;
},
set name(value) {
this._name = value;
},
get surname() {
return this._surname;
},
set surname(value) {
this._surname = value;
},
get fullName() {
return `${this._name} ${this._surname}`
}
}
// properties starting with an …
beginners data flexibility javascript name object return security value webdev
More from dev.to / DEV Community
Jobs in InfoSec / Cybersecurity
Information Security Engineers
@ D. E. Shaw Research | New York City
Technology Security Analyst
@ Halton Region | Oakville, Ontario, Canada
Senior Cyber Security Analyst
@ Valley Water | San Jose, CA
Consultant/Senior Consultant – Categoria Protetta L. 68/99
@ BIP | Italy
SoC Security Architect, Platform Architecture
@ Apple | San Diego, California, United States
Cloud Engineer II- SOC Analyst
@ Insight Enterprises, Inc. | Gurugram Gurgaon HR, IN