A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 101
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Router::$uri is deprecated
Filename: core/Router.php
Line Number: 127
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$benchmark is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$hooks is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$config is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$log is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$utf8 is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$uri is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$exceptions is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$router is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$output is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$security is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$input is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$lang is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$db is deprecated
Filename: core/Loader.php
Line Number: 396
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_DB_mysqli_driver::$failover is deprecated
Filename: database/DB_driver.php
Line Number: 371
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Trying to access array offset on true
Filename: libraries/Email.php
Line Number: 978
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$email is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 295
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 169
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 238
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 318
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 359
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 289
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Session cannot be started after headers have already been sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$session is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$user_model is deprecated
Filename: core/Loader.php
Line Number: 358
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$load is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$pgmodule is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$benchmark is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$hooks is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$config is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$log is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$utf8 is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$uri is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$exceptions is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$router is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$output is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$security is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$input is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$lang is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$db is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$email is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$session is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$user_model is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
Methods of primitives in JavaScript | Post Details - SKML Home Tuitions
Methods of primitives in JavaScript
JavaScript allows us to work with primitives (strings, numbers, etc.) as if they were objects. They also provide methods to call as such.
Let’s look at the key distinctions between primitives and objects.
A primitive
Is a value of a primitive type.
There are 7 primitive types: string, number, bigint, boolean, symbol, null and undefined.
An object
Is capable of storing multiple values as properties.
Can be created with {}, for instance: {name: "John", age: 30}. There are other kinds of objects in JavaScript: functions, for example, are objects.
One of the best things about objects is that we can store a function as one of its properties.
let john = {
name: "John",
sayHi: function() {
alert("Hi buddy!");
}
};
john.sayHi(); // Hi buddy!
So here we’ve made an object john with the method sayHi.
Many built-in objects already exist, such as those that work with dates, errors, HTML elements, etc. They have different properties and methods.
But these features come with a cost!
Objects are “heavier” than primitives. They require additional resources to support the internal machinery.
A primitive as an object
Here’s the paradox faced by the creator of JavaScript:
There are many things one would want to do with a primitive like a string or a number. It would be great to access them as methods.
Primitives must be as fast and lightweight as possible.
The solution looks a little bit awkward, but here it is:
Primitives are still primitive. A single value, as desired.
The language allows access to methods and properties of strings, numbers, booleans and symbols.
In order for that to work, a special “object wrapper” that provides the extra functionality is created, and then is destroyed.
The “object wrappers” are different for each primitive type and are called: String, Number, Boolean and Symbol. Thus, they provide different sets of methods.
For instance, there exists a string method str.toUpperCase() that returns a capitalized str.
Here’s how it works:
let str = "Hello";
alert( str.toUpperCase() ); // HELLO
Simple, right? Here’s what actually happens in str.toUpperCase():
The string str is a primitive. So, in the moment of accessing its property, a special object is created that knows the value of the string, and has useful methods, like toUpperCase().
That method runs and returns a new string (shown by alert).
The special object is destroyed, leaving the primitive str alone.
So, primitives can provide methods, but they still remain lightweight.
The JavaScript engine highly optimizes this process. It may even skip the creation of the extra object at all. But it must still adhere to the specification and behave as if it creates one.
A number has methods of its own, for instance, toFixed(n) rounds the number to the given precision:
let n = 1.23456;
alert( n.toFixed(2) ); // 1.23
We’ll see more specific methods in chapters Numbers and Strings .
Constructors String/Number/Boolean are for internal use only
Some languages like Java allow us to explicitly create “wrapper objects” for primitives using a syntax like new Number(1) or new Boolean(false).
In JavaScript, that’s also possible for historical reasons, but highly unrecommended. Things will go crazy in several places.
For instance:
alert( typeof 0 ); // "number"
alert( typeof new Number(0) ); // "object"!
Objects are always truthy in if, so here the alert will show up:
let zero = new Number(0);
if (zero) { // zero is true, because it's an object
alert( "zero is truthy!?!" );
}
On the other hand, using the same functions String/Number/Boolean without new is a totally sane and useful thing. They convert a value to the corresponding type: to a string, a number, or a boolean (primitive).
For example, this is entirely valid:
let num = Number(“123”); // convert a string to number
null/undefined have no methods
The special primitives null and undefined are exceptions. They have no corresponding “wrapper objects” and provide no methods. In a sense, they are “the most primitive”.
An attempt to access a property of such value would give the error:
alert(null.test); // error
Summary
Primitives except null and undefined provide many helpful methods.
Formally, these methods work via temporary objects, but JavaScript engines are well tuned to optimize that internally, so they are not expensive to call.
Not sure whare to join tuition right for you?
Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.
Let`s Connect