❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Hoisting – Javascript

By: Elavarasu
25 October 2024 at 10:38

Hoisting :
we can use variable before creating

message = β€œhello” // without creating variable
console.log(message);
var message; // this type of declaration is hoisting type in JavaScript.

// Hoisting

/ Hoisting

function codeHoist(){
a = 10;
let b = 50;
}
codeHoist();
console.log(a); //10
console.log(b); //Reference Error b is not defined

JAVASCRIPT

By: Elavarasu
25 October 2024 at 09:56

JavaScript is a versatile programming language primarily used to create dynamic and interactive features on websites.
JavaScript is a scripting language that allows you to implement complex features on web pages.
Browsers have Interpreters. It will converts JAVASCRIPT code to machine code.
Browsers have its own interpreters like

  • Chrome – V8-engine
  • Edge – Chakra

JavaScript- Identifiers :

var message; –> Variable (Identifier)
message = β€˜Javascript’;

func sayHello() {
console.log(β€˜Hello’)
}

//sayHello Is the identifier for this function.

//variables , objects,functions,arrays ,classes names are identifiers in js.

SCOPE :
In JavaScript, scope refers to the context in which variables and functions are accessible. It determines the visibility and lifetime of these variables and functions within your code. There are three main types of scope in JavaScript.

Global Scope:.

  • Variables declared outside any function or block have global scope.
  • These variables are accessible from anywhere in the code

example :

let globalVar = "I'm global";

function test() {
  console.log(globalVar); // Accessible here
}

test();
console.log(globalVar); // Accessible here too

Function Scope

  • Variables declared within a function are local to that function.
  • They cannot be accessed from outside the function.

example :

function test() {
  let localVar = "I'm local";
  console.log(localVar); // Accessible here
}

test();
console.log(localVar); // Error: localVar is not defined

Block Scope:

  • Introduced with ES6, variables declared withΒ letΒ orΒ constΒ within a block (e.g., insideΒ {}) are only accessible within that block

example :

{
  let blockVar = "I'm block-scoped";
  console.log(blockVar); // Accessible here
}

console.log(blockVar); // Error: blockVar is not defined

Keywords | Reserved Words

Keywords are reserved words in JavaScript that cannot use to indicate variable labels or function names.

Variables

variables ==> stored values ==> it will stored to ram / It will create separate memory.so we need memory address for access the values.

Stores Anything :
JavaScript will store any value in the variable.

Declaring Variable :

 * Var
 * let
 * const    

we can declare variable using above keywords:

Initialize Variable :

Using assignment operator to assign the value to the variables.

var text = "hello";

Hoisting – Javascript

By: Elavarasu
25 October 2024 at 10:38

Hoisting :
we can use variable before creating

message = β€œhello” // without creating variable
console.log(message);
var message; // this type of declaration is hoisting type in JavaScript.

// Hoisting

/ Hoisting

function codeHoist(){
a = 10;
let b = 50;
}
codeHoist();
console.log(a); //10
console.log(b); //Reference Error b is not defined

JAVASCRIPT

By: Elavarasu
25 October 2024 at 09:56

JavaScript is a versatile programming language primarily used to create dynamic and interactive features on websites.
JavaScript is a scripting language that allows you to implement complex features on web pages.
Browsers have Interpreters. It will converts JAVASCRIPT code to machine code.
Browsers have its own interpreters like

  • Chrome – V8-engine
  • Edge – Chakra

JavaScript- Identifiers :

var message; –> Variable (Identifier)
message = β€˜Javascript’;

func sayHello() {
console.log(β€˜Hello’)
}

//sayHello Is the identifier for this function.

//variables , objects,functions,arrays ,classes names are identifiers in js.

SCOPE :
In JavaScript, scope refers to the context in which variables and functions are accessible. It determines the visibility and lifetime of these variables and functions within your code. There are three main types of scope in JavaScript.

Global Scope:.

  • Variables declared outside any function or block have global scope.
  • These variables are accessible from anywhere in the code

example :

let globalVar = "I'm global";

function test() {
  console.log(globalVar); // Accessible here
}

test();
console.log(globalVar); // Accessible here too

Function Scope

  • Variables declared within a function are local to that function.
  • They cannot be accessed from outside the function.

example :

function test() {
  let localVar = "I'm local";
  console.log(localVar); // Accessible here
}

test();
console.log(localVar); // Error: localVar is not defined

Block Scope:

  • Introduced with ES6, variables declared withΒ letΒ orΒ constΒ within a block (e.g., insideΒ {}) are only accessible within that block

example :

{
  let blockVar = "I'm block-scoped";
  console.log(blockVar); // Accessible here
}

console.log(blockVar); // Error: blockVar is not defined

Keywords | Reserved Words

Keywords are reserved words in JavaScript that cannot use to indicate variable labels or function names.

Variables

variables ==> stored values ==> it will stored to ram / It will create separate memory.so we need memory address for access the values.

Stores Anything :
JavaScript will store any value in the variable.

Declaring Variable :

 * Var
 * let
 * const    

we can declare variable using above keywords:

Initialize Variable :

Using assignment operator to assign the value to the variables.

var text = "hello";

React -Router

By: Elavarasu
17 October 2024 at 05:08

Understanding Routes

React- Router is used for render the components depends on URL without reloading the browser page. It navigates a page to another page without page reloads. we can use router in react project, first we install the react-router-dom package from react.

Then, access the router using

import {BrowserRouter,Router,Routes} from 'react-router-dom';

after that we use link to diplay the browser using Link instead <a href=''> in react.

so,

import {BrowserRouter,Router,Routes,Link} from β€˜react-router-dom’;

example for using Link and routes:

Using Links:

  '/' is the root page it display default home page

    <Link to='/'>Home</Link>
    <Link to='/about'>About</Link>
    <Link to='/contact'>Contact</Link>

}/> }> }/>

Using Routes:

<Browser Router>
<Router>
<Routes path='/' element={<Home/>}/>
<Routes path='/about' element={<About/>}>
<Routes path='/contact' element={<Contact/>}/>
</Router>
</Browser Router>

React -Router

By: Elavarasu
17 October 2024 at 05:08

Understanding Routes

React- Router is used for render the components depends on URL without reloading the browser page. It navigates a page to another page without page reloads. we can use router in react project, first we install the react-router-dom package from react.

Then, access the router using

import {BrowserRouter,Router,Routes} from 'react-router-dom';

after that we use link to diplay the browser using Link instead <a href=''> in react.

so,

import {BrowserRouter,Router,Routes,Link} from β€˜react-router-dom’;

example for using Link and routes:

Using Links:

  '/' is the root page it display default home page

    <Link to='/'>Home</Link>
    <Link to='/about'>About</Link>
    <Link to='/contact'>Contact</Link>

}/> }> }/>

Using Routes:

<Browser Router>
<Router>
<Routes path='/' element={<Home/>}/>
<Routes path='/about' element={<About/>}>
<Routes path='/contact' element={<Contact/>}/>
</Router>
</Browser Router>

Install postgres & pgadmin

By: Elavarasu
20 September 2024 at 16:57

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

To manually configure the Apt repository, follow these steps:

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc –fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c β€˜echo β€œdeb

[signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc]

https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’
sudo apt update
sudo apt -y install postgresql

sudo -i -u postgres

psql

\q

createdb my_pgdb

psql -d my_pgdb

\conninfo

After the we have download pgadmin using cmd :

#
# Setup the repository
#

# Install the public key for the repository (if not done previously):
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

#
# Install pgAdmin
#

# Install for both desktop and web modes:
sudo apt install pgadmin4

# Install for desktop mode only:
sudo apt install pgadmin4-desktop

# Install for web mode only:
sudo apt install pgadmin4-web

# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh

After tat setting password for pgadmin

sudo -i -u postgres

psql

\password postgres

Enter new pasword :

Enter it again


Reference : https://www.postgresql.org/download/linux/ubuntu/

https://www.pgadmin.org/download/pgadmin-4-apt/


Install postgres & pgadmin

By: Elavarasu
20 September 2024 at 16:57

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

To manually configure the Apt repository, follow these steps:

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc –fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c β€˜echo β€œdeb

[signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc]

https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’
sudo apt update
sudo apt -y install postgresql

sudo -i -u postgres

psql

\q

createdb my_pgdb

psql -d my_pgdb

\conninfo

After the we have download pgadmin using cmd :

#
# Setup the repository
#

# Install the public key for the repository (if not done previously):
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

#
# Install pgAdmin
#

# Install for both desktop and web modes:
sudo apt install pgadmin4

# Install for desktop mode only:
sudo apt install pgadmin4-desktop

# Install for web mode only:
sudo apt install pgadmin4-web

# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh

After tat setting password for pgadmin

sudo -i -u postgres

psql

\password postgres

Enter new pasword :

Enter it again


Reference : https://www.postgresql.org/download/linux/ubuntu/

https://www.pgadmin.org/download/pgadmin-4-apt/


Eclipse closes automatically when Using β€˜System.out.println’

By: Elavarasu
4 June 2024 at 00:07

I’m experiencing an issue with Eclipse where it closes automatically when I use β€˜System.out.println’.

Environment :
Eclipse Version: eclipse 2024-03 is the latest version of Eclipse today I reinstalled it.
I downloaded Eclipse from the official Eclipse Foundation website at Eclipse Downloads | The Eclipse Foundation 1.

JDK version : java 22.0.1 2024-04-16
Javaβ„’ SE Runtime Environment (build 22.0.1+8-16)
Java HotSpotβ„’ 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

Operating System: Ubuntu Ubuntu 22.04.4 LTS

Problem Description: Whenever I run a simple Java program that uses System.out.println. Eclipse hung and closed automatically without getting any error messages.

How i fix this issue

I fix this issue

Hi everyone,

I recently encountered a problem with Eclipse. when I upgraded Ubuntu 20 to Ubuntu 22 then some applications did not work properly . After some troubleshooting, I discovered that switching from Wayland to X11 resolved the issue. Here’s how you can do it:

How to Switch from Wayland to X11 on Ubuntu

If you’re experiencing issues with Wayland and want to switch back to X11, follow these steps:

Turn off Wayland and switch back to X11.

  1. Log out of Ubuntu.
  2. Start to log in again and click the icon that has appeared at the bottom right of the screen – that gives you the option to disable Wayland.
  3. Switch back to Xorg.

Switching to X11 fixed the issues I was having, so I hope this helps anyone experiencing similar problems. Let me know if you have any questions or need further assistance!

Eclipse closes automatically when Using β€˜System.out.println’

By: Elavarasu
4 June 2024 at 00:07

I’m experiencing an issue with Eclipse where it closes automatically when I use β€˜System.out.println’.

Environment :
Eclipse Version: eclipse 2024-03 is the latest version of Eclipse today I reinstalled it.
I downloaded Eclipse from the official Eclipse Foundation website at Eclipse Downloads | The Eclipse Foundation 1.

JDK version : java 22.0.1 2024-04-16
Javaβ„’ SE Runtime Environment (build 22.0.1+8-16)
Java HotSpotβ„’ 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

Operating System: Ubuntu Ubuntu 22.04.4 LTS

Problem Description: Whenever I run a simple Java program that uses System.out.println. Eclipse hung and closed automatically without getting any error messages.

How i fix this issue

I fix this issue

Hi everyone,

I recently encountered a problem with Eclipse. when I upgraded Ubuntu 20 to Ubuntu 22 then some applications did not work properly . After some troubleshooting, I discovered that switching from Wayland to X11 resolved the issue. Here’s how you can do it:

How to Switch from Wayland to X11 on Ubuntu

If you’re experiencing issues with Wayland and want to switch back to X11, follow these steps:

Turn off Wayland and switch back to X11.

  1. Log out of Ubuntu.
  2. Start to log in again and click the icon that has appeared at the bottom right of the screen – that gives you the option to disable Wayland.
  3. Switch back to Xorg.

Switching to X11 fixed the issues I was having, so I hope this helps anyone experiencing similar problems. Let me know if you have any questions or need further assistance!

this keyword

By: Elavarasu
12 March 2024 at 13:55
  • this is a java keyword this keyword refers to current object of the same class
  • this keyword helps to differentiate between local variable and global instance variable
  • we cannot use this keyword inside static context. [static method or static block].
  • this only used for object specific.
class Shop
{
static String shopName ="Updatez";
int price, discount; // non-static variable
public static void main(String args[])
{
Shop product = new Shop();
product.price =1000;
product.discount =10;

s.sell(); // method calling
}

void sell()
{
int discount = 30; // local variable
System.out.println(discount);30
System.out.println(this.price);
System.out.println(this.discount);
}
}

output:
30
1000
10

we cannot use this keyword inside the static method and also a main method


Scanner |Java

By: Elavarasu
12 March 2024 at 09:50

import java.util.Scanner;

Scanner sc = new Scanner(System.in);

A simple text scanner that can parse primitive types and strings using regular expressions.
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods.

Scanner sc = new Scanner(System.in);
System.out.println("Enter the value:");
int value =sc.nextInt();
System.out.println(value);
  • int –> nextInt()
  • long –>nextLong()
  • short –>nextShort()
  • float –> nextFloat()
  • double –> nextDouble()
  • boolean –> nextBoolean()
  • String –> nextLine() & next()

reference:https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

Fields in Java

By: Elavarasu
11 March 2024 at 18:23

Fields are categorized by various data types in java.

Methods -> set of Instructions with a name for a specific task.

Data types in java :

Java programming language is statically typed, means all variables must first be declared before being used.

  • Primitive
  • Non-Primitive

Primitive Data types in java :

Fields | global variables

  • class specific fields
  • object specific fields

Field is a data member of a class. Unless specified otherwise, a field is not static.

  • static variables
  • non-static variables

Static variables:

  • common variables for all objects
  • static members will have only one copy in memory. but static is not constant.
  • values will change.
  • static varibles depends on whole class. so, its a class specific variables.
static String owner_name ="Elavarasu";

Non-static variables: | Instance [object specific]

  • specific to each objects.
  • non-static members will have multiples copies in memory
  • it depends only a object. so it is object specific.
String employee = "name";

Source-Code:


Reference : https://www.shiksha.com/online-courses/articles/data-types-in-java-primitive-and-non-primitive-data-types/

this keyword

By: Elavarasu
12 March 2024 at 13:55
  • this is a java keyword this keyword refers to current object of the same class
  • this keyword helps to differentiate between local variable and global instance variable
  • we cannot use this keyword inside static context. [static method or static block].
  • this only used for object specific.
class Shop
{
static String shopName ="Updatez";
int price, discount; // non-static variable
public static void main(String args[])
{
Shop product = new Shop();
product.price =1000;
product.discount =10;

s.sell(); // method calling
}

void sell()
{
int discount = 30; // local variable
System.out.println(discount);30
System.out.println(this.price);
System.out.println(this.discount);
}
}

output:
30
1000
10

we cannot use this keyword inside the static method and also a main method


Scanner |Java

By: Elavarasu
12 March 2024 at 09:50

import java.util.Scanner;

Scanner sc = new Scanner(System.in);

A simple text scanner that can parse primitive types and strings using regular expressions.
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods.

Scanner sc = new Scanner(System.in);
System.out.println("Enter the value:");
int value =sc.nextInt();
System.out.println(value);
  • int –> nextInt()
  • long –>nextLong()
  • short –>nextShort()
  • float –> nextFloat()
  • double –> nextDouble()
  • boolean –> nextBoolean()
  • String –> nextLine() & next()

reference:https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

❌
❌