Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
11// Creating a hash table using a JavaScript object
const hashTable = {};
// Adding key-value pairs to the hash table
hashTable["name"] = "Alice";
hashTable["age"] = 30;
hashTable["occupation"] = "Engineer";
// Accessing values by their keys
console.log(hashTable["name"]); // Output: Alice
console.log(hashTable["age"]); // Output: 30
console.log(hashTable["occupation"]); // Output: Engineer
// Removing a key-value pair
delete hashTable["age"];
// Checking if a key exists
if ("age" in hashTable) {
console.log("Age key exists");
} else {
console.log("Age key does not exist");
}
Code panel - press c to focus line 1.
// C// Creating a hash table using a JavaScript object
const hashTable = {};
// Adding key-value pairs to the hash table
hashTable["name"] = "Alice";
hashTable["age"] = 30;
hashTable["occupation"] = "Engineer";
// Accessing values by their keys
console.log(hashTable["name"]); // Output: Alice
console.log(hashTable["age"]); // Output: 30
console.log(hashTable["occupation"]); // Output: Engineer
// Removing a key-value pair
delete hashTable["age"];
// Checking if a key exists
if ("age" in hashTable) {
console.log("Age key exists");
} else {
console.log("Age key does not exist");
opyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_lifetime_monitor.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extension_host_registry.h"
#include "extensions/browser/extensions_browser_client.h"
namespace apps {
// static
AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
content::BrowserContext* context) {
return static_cast<AppLifetimeMonitor*>(
GetInstance()->GetServiceForBrowserContext(context, false));
}
AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
return base::Singleton::get();
}
AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
: BrowserContextKeyedServiceFactory(
"AppLifetimeMonitor",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
DependsOn(extensions::ExtensionHostRegistry::GetFactory());
}
AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new AppLifetimeMonitor(context);
}
bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return extensions::ExtensionsBrowserClient::Get()->
GetOriginalContext(context);
}
} // namespace apps
// Creating a hash table using a JavaScript object
const hashTable = {};
// Adding key-value pairs to the hash table
hashTable["name"] = "Alice";
hashTable["age"] = 30;
hashTable["occupation"] = "Engineer";
// Accessing values by their keys
console.log(hashTable["name"]); // Output: Alice
console.log(hashTable["age"]); // Output: 30
console.log(hashTable["occupation"]); // Output: Engineer
// Removing a key-value pair
delete hashTable["age"];
// Checking if a key exists
if ("age" in hashTable) {
console.log("Age key exists");
} else {
console.log("Age key does not exist");
}
Code panel - press c to focus line 1.
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
#include "apps/app_lifetime_monitor_factory.h"
#include "apps/app_lifetime_monitor.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "content/public/browser/browser_context.h" #include "extensions/browser/app_window/app_window_registry.h" #include "extensions/browser/extension_host_registry.h" #include "extensions/browser/extensions_browser_client.h"
namespace apps {
// static
AppLifetimeMonitor* AppLifetimeMonitorFactory::GetForBrowserContext(
content::BrowserContext* context) {
return static_cast<AppLifetimeMonitor*>(
GetInstance()->GetServiceForBrowserContext(context, false));
}
AppLifetimeMonitorFactory* AppLifetimeMonitorFactory::GetInstance() {
return base::Singleton::get();
}
AppLifetimeMonitorFactory::AppLifetimeMonitorFactory()
: BrowserContextKeyedServiceFactory(
"AppLifetimeMonitor",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(extensions::AppWindowRegistry::Factory::GetInstance());
DependsOn(extensions::ExtensionHostRegistry::GetFactory());
}
AppLifetimeMonitorFactory::~AppLifetimeMonitorFactory() = default;
KeyedService* AppLifetimeMonitorFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new AppLifetimeMonitor(context);
}
bool AppLifetimeMonitorFactory::ServiceIsCreatedWithBrowserContext() const {
return true;
}
content::BrowserContext* AppLifetimeMonitorFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return extensions::ExtensionsBrowserClient::Get()->
GetOriginalContext(context);
}
} // namespace apps