JavaScript Cheat Sheet — JSON, Loops, and Promises

JavaScript is one of the most popular programming languages for web programming.

In this article, we’ll look at the basic syntax of modern JavaScript


We can create JSON strings from JavaScript objects with the JSON.stringify method:

And we can convert JSON strings back to JavaScript objects with JSON.parse :

const obj = JSON.parse(json);

We can use it to store data in local storage.

We’ve to convert objects into strings first to store them.

To store objects we call localStorage.setItem :

The first argument is the key.

And we can get data by their keys with getItem :



avaScript comes with various kinds of loops.

One kind of loop is the for loop:

for (let i = 0; i < 10; i++) { console.log(i); }

We can loop through any kind of iterable object with the for-of loop:

for (let i of custOrder) { console.log(i); }

Some iterable objects include arrays, strings, and node lists.

Another kind of loop is the while loop:

There’s also the do-while loop:

The break keyword lets us end the loop early:

The continue keyword lets us skip to the next iteration:

Data Types

JavaScript comes with various data types.

They include:


We can create an object with curly braces:

It has properties and methods.

this is the student object itself.

We can call fullName with student.fullName() .

And we can assign values to properties with:

student.age = 19;


We can create promises with the Promise constructor:

We can resolve to fulfill the promise with the sum.

And we call reject to reject the promise with an error.

Then we can call then to get the resolved value and catch to get the error values:


We can work with JSON, local storage, promises, and loops with JavaScript.

Tagged : / / /

General error: 1364 Field ‘phone’ doesn’t have a default value

SQLSTATE[HY000]: General error: 1364 Field ‘phone’ doesn’t have a default value (SQL: insert into `products` (`name`, `email`, `address`, `image`, `updated_at`, `created_at`) values (amti,, sdafasdf, 642917381.jpg, 2021–05–11 10:58:35, 2021–05–11 10:58:35))

When I’m submit form then got General error field doesn’t have default value. let’s go to solve this.

👉 1 step go to your database and put change none>to Null and save.

Lets go to phpmyadmin

👉 Click on Structure

Click on change and change all field to None to Null and save

Set Null and click on save button

👁👁 Now its error has been solved and your data has been stored successfully.


Tagged : / / / / / /

How to Store Multiple Records using Checkbox in Laravel?

First Part: first of all, we will learn how to design or getdata in blade file

In table we will set one field default value as no while migrating data


In blade file we will create one table

Next, in js we will create one fetch function

onclick java script function

Routing:set route

Route::prefix(‘/touroperator’)->group(function () use ($namespace) {

$controller = $namespace.'\TourDashboardController';
$tourcontroller = $namespace.'\TourDetailController';



create function in client side controller

Set env file:


Set Config file:

GET_MYHOLIDAYTRIP_URL’ => env(‘GET_MYHOLIDAYTRIP_URL’, ‘not found in .env file’),

Routing set Server side:

Route::get(‘gettripdetail/{email}’, ‘Admin\AdminTPController@tripdetail’);

Create function in server side:

Second Part: thereafter, we will learn how to store data after selecting in blade file

Set Routing(Client side microservice) :

Route::prefix(‘/touroperator’)->group(function () use ($namespace) {

$controller = $namespace.'\TourDashboardController';
$tourcontroller = $namespace.'\TourDetailController';

Route::post(‘permissiontour/{email}’, ‘AdminController@addpermission’)->name(‘permissiontour’);

Create function in client side controller

Set Env file


config file:

‘PERMIT_TRIP_URL’ => env(‘PERMIT_TRIP_URL’, ‘not found in .env file’), 

Set Routing in server side Microservice

Route::post(‘/permittrip’, ‘Admin\AdminTPController@storepermission’);

Create function in controller server side microservice

Tagged : /

Laravel Error: Creating default object from empty value when store data

today,I am updating data in one table(package table), but I wrote different modal name Trip Category

So,be careful while you are updating data ,choose correct modal name

Tagged :