Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Manisha Patil
Page 4 of 4
Passing unknown number of arguments to a function in Javascript
JavaScript allows functions to accept any number of arguments, even if the function definition specifies a different number of parameters. This flexibility is useful when creating functions that need to handle variable amounts of data. When defining a function, the variables listed in parentheses are called parameters. When calling the function, the actual values passed are called arguments. JavaScript provides two main approaches to handle unknown numbers of arguments. Basic Example: Fixed Parameters Functions with fixed parameters will only use the specified number of arguments, ignoring any extras: Passing ...
Read MoreWhat is the drawback of creating true private methods in JavaScript?
Private methods in JavaScript provide encapsulation by hiding internal functionality from external code. While they offer significant benefits like preventing naming conflicts and creating clean interfaces, true private methods come with notable drawbacks that developers should understand. JavaScript supports private methods through closures (using var, let, const) and ES2022 private class fields (using # prefix). Both approaches create truly private methods that cannot be accessed from outside the class. Main Drawbacks of True Private Methods Creating true private methods in JavaScript has two primary drawbacks: No External Access: Private methods cannot be called from outside ...
Read More