Skip to content

What is the "NEW " used for? #109

Answered by FrankBevr
Sairam002 asked this question in Q&A
Discussion options

You must be logged in to vote

The new Keyword says that you intaniate a new Object.
I guess the best way to explain it is to refer to this Video.
He explains the new Keyword and what does it mean.
FireShip Javascript - Refresher

Ethers allow you to create a provider to connect to your Blockchain, so you can instantiate a new provider with

new ethers.providers.JsonRpcProvider(process.env.RPC_URL);

and then you safe it your own declared variable

Do you need a Wallet, then make a new Wallet with new ethers.Wallet()
Do you need a XY, then make a new XY with new XY()
and so on

if you dont want to create something, because you just want something, like a string then you just call a function. f.e. LikeThis

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sairam002
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants