Ashab Uddin

1613692140

5 Things You Need to Know About Delete Operator in JavaScript | Interview guide

In JavaScript, the delete operator is employed to delete a property of an object. After deleting the actual property, that property won’t be accessible and returns undefined.
The invocation of the delete operator returns true when it removes a property and false otherwise. it’s only effective on an object’s properties, it has no effect on variable or function names.
The delete operator shouldn’t be used on predefined JavaScript object properties like window, Math, and Date objects. It can crash your application.
Let’s scrutinize some facts about the delete operator.
Delete object properties
The only way to fully remove the properties of an object in JavaScript is by using delete operator.
If the property which you’re trying to delete doesn’t exist, delete won’t have any effect and can return true.
Can we delete variables in Javascript?
The delete operator removes a property from an object. It cannot delete a variable. Any property declared with var cannot be deleted from the global scope or from a function’s scope.
If you declare a variable without var, it can be deleted. Let’s look into the example below.
The variable declared without the var keyword internally stores it as a property of the window object. So we can delete the properties of the window object.
Can we delete values from an array?
Since JavaScript arrays are objects, elements can be deleted by using delete.
delete will delete the object property, but will not reindex the array or update its length. This makes it appear as if it is undefined.
Using delete may leave undefined holes in the array. Use pop(), shift(), or splice() instead.
Deleting built-in objects like Math, Date, and window objects is unsafe, and it can crash your entire application.
Deleting non-configurable properties
Object properties, besides a value, has three special attributes:
writable – if true, the value can be changed, otherwise it’s read-only.
enumerable – if true, it is listed in loops, otherwise not listed.
configurable – if true, the property can be deleted or the attributes can be modified, otherwise it cannot be changed.
The values assigned by using Object.defineProperty and set to configurable: false in an object cannot be deleted.
In strict mode, it will throw an error if you try to delete a non-configurable property.
delete is the only true way to remove an object’s properties without any leftovers, but it works ~100 times slower if you are using delete in loops.
The alternative solution is setting the value to undefined like object[key] = undefined. It doesn’t fully delete the property, it just sets value to undefined. the choice isn’t exactly a prominent solution, but if you utilize it with care then you’ll be able to improve the performance.

Source Code: https://github.com/jayanthbabu123/5-things-about-delete-operator-in-javascript

Subscribe: https://www.youtube.com/channel/UCNVKOc0Ya-MVHElzxT7htxw

#js #javascript

What is GEEK

Buddha Community

5 Things You Need to Know About Delete Operator in JavaScript | Interview guide

Santosh J

1622036598

JavaScript compound assignment operators

JavaScript is unarguablly one of the most common things you’ll learn when you start programming for the web. Here’s a small post on JavaScript compound assignment operators and how we use them.

The compound assignment operators consist of a binary operator and the simple assignment operator.

The binary operators, work with two operands. For example a+b where + is the operator and the a, b are operands. Simple assignment operator is used to assign values to a variable(s).

It’s quite common to modify values stored in variables. To make this process a little quicker, we use compound assignment operators.

They are:

  • +=
  • -+
  • *=
  • /=

You can also check my video tutorial compound assignment operators.

Let’s consider an example. Suppose price = 5 and we want to add ten more to it.

var price = 5;
price = price + 10;

We added ten to price. Look at the repetitive price variable. We could easily use a compound += to reduce this. We do this instead.

price += 5;

Awesome. Isn’t it? What’s the value of price now? Practice and comment below. If you don’t know how to practice check these lessons.

Lets bring down the price by 5 again and display it.
We use console.log command to display what is stored in the variable. It is very help for debugging.
Debugging let’s you find errors or bugs in your code. More on this later.

price -= 5;
console.log(price);

Lets multiply price and show it.

price *=5;
console.log(price);

and finally we will divide it.

price /=5;
console.log(price);

If you have any doubts, comment below.

#javascript #javascript compound assignment operators #javascript binary operators #javascript simple assignment operator #doers javascript

Ashab Uddin

1613692140

5 Things You Need to Know About Delete Operator in JavaScript | Interview guide

In JavaScript, the delete operator is employed to delete a property of an object. After deleting the actual property, that property won’t be accessible and returns undefined.
The invocation of the delete operator returns true when it removes a property and false otherwise. it’s only effective on an object’s properties, it has no effect on variable or function names.
The delete operator shouldn’t be used on predefined JavaScript object properties like window, Math, and Date objects. It can crash your application.
Let’s scrutinize some facts about the delete operator.
Delete object properties
The only way to fully remove the properties of an object in JavaScript is by using delete operator.
If the property which you’re trying to delete doesn’t exist, delete won’t have any effect and can return true.
Can we delete variables in Javascript?
The delete operator removes a property from an object. It cannot delete a variable. Any property declared with var cannot be deleted from the global scope or from a function’s scope.
If you declare a variable without var, it can be deleted. Let’s look into the example below.
The variable declared without the var keyword internally stores it as a property of the window object. So we can delete the properties of the window object.
Can we delete values from an array?
Since JavaScript arrays are objects, elements can be deleted by using delete.
delete will delete the object property, but will not reindex the array or update its length. This makes it appear as if it is undefined.
Using delete may leave undefined holes in the array. Use pop(), shift(), or splice() instead.
Deleting built-in objects like Math, Date, and window objects is unsafe, and it can crash your entire application.
Deleting non-configurable properties
Object properties, besides a value, has three special attributes:
writable – if true, the value can be changed, otherwise it’s read-only.
enumerable – if true, it is listed in loops, otherwise not listed.
configurable – if true, the property can be deleted or the attributes can be modified, otherwise it cannot be changed.
The values assigned by using Object.defineProperty and set to configurable: false in an object cannot be deleted.
In strict mode, it will throw an error if you try to delete a non-configurable property.
delete is the only true way to remove an object’s properties without any leftovers, but it works ~100 times slower if you are using delete in loops.
The alternative solution is setting the value to undefined like object[key] = undefined. It doesn’t fully delete the property, it just sets value to undefined. the choice isn’t exactly a prominent solution, but if you utilize it with care then you’ll be able to improve the performance.

Source Code: https://github.com/jayanthbabu123/5-things-about-delete-operator-in-javascript

Subscribe: https://www.youtube.com/channel/UCNVKOc0Ya-MVHElzxT7htxw

#js #javascript

Niraj Kafle

1589255577

The essential JavaScript concepts that you should understand

As a JavaScript developer of any level, you need to understand its foundational concepts and some of the new ideas that help us developing code. In this article, we are going to review 16 basic concepts. So without further ado, let’s get to it.

#javascript-interview #javascript-development #javascript-fundamental #javascript #javascript-tips

Rahul Jangid

1622207074

What is JavaScript - Stackfindover - Blog

Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.

Who invented JavaScript?

JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.

What is JavaScript?

JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.

Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.

JavaScript Hello World Program

In JavaScript, ‘document.write‘ is used to represent a string on a browser.

<script type="text/javascript">
	document.write("Hello World!");
</script>

How to comment JavaScript code?

  • For single line comment in JavaScript we have to use // (double slashes)
  • For multiple line comments we have to use / * – – * /
<script type="text/javascript">

//single line comment

/* document.write("Hello"); */

</script>

Advantages and Disadvantages of JavaScript

#javascript #javascript code #javascript hello world #what is javascript #who invented javascript

Seamus  Quitzon

Seamus Quitzon

1595201363

Php how to delete multiple rows through checkbox using ajax in laravel

First thing, we will need a table and i am creating products table for this example. So run the following query to create table.

CREATE TABLE `products` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Next, we will need to insert some dummy records in this table that will be deleted.

INSERT INTO `products` (`name`, `description`) VALUES

('Test product 1', 'Product description example1'),

('Test product 2', 'Product description example2'),

('Test product 3', 'Product description example3'),

('Test product 4', 'Product description example4'),

('Test product 5', 'Product description example5');

Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name','description'
    ];
}

Step 2: Create Route

Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.

routes/web.php

Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);

#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete