Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript pass

Is there something along the lines of python 'pass' in javascript?

I want to do the javascript equivalent of:

try:   # Something that throws exception catch:   pass 
like image 818
Intra Avatar asked May 23 '12 20:05

Intra


People also ask

What is pass JavaScript?

Javascript pass by value: That is, JavaScript copies the values of the passing variables into arguments inside of the function. //javascript pass by value function square(x) { x = x * x; return x; } var y = 10; var result = square(y); console. log(y); // 10 -- no change console.

Does JavaScript have a pass keyword?

The this keyword is a crucial idea in JavaScript. In JavaScript, this is a handle to an object. The object that this relates to can alter, intuitively, based on whether it is public, on an entity, or in a constructor.

Is JavaScript pass by reference or value?

JavaScript is always pass-by-value. This means everything in JavaScript is a value type and function arguments are always passed by value. That being said, object types are a bit more confusing. The confusion lies in the fact that object types are reference types which are passed by value.

How are objects passed in JavaScript?

In JavaScript, object references are values. Because of this, objects will behave like they are passed by reference: If a function changes an object property, it changes the original value. Changes to object properties are visible (reflected) outside the function.


1 Answers

pass is a no-op in Python. You need it for empty blocks because

try:     # Something that throws exception catch:  # continue other stuff 

is a syntax error. In JavaScript you can just use an empty catch block.

try {     // Something that throws exception } catch (e) {} 
like image 102
Matt Ball Avatar answered Sep 29 '22 07:09

Matt Ball